package top.lixunda.ecommerce.server.user.api.entity.vo;

import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;
import top.lixunda.common.utils.ObjectValidators;
import top.lixunda.ecommerce.server.user.api.entity.db.BusinessTaskItemDO;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 代办任务子项返回结果VO，对应每个人员的任务分配情况
 *
 * @author lixunda
 * @version time:2020/4/13 14:02
 */
@ApiModel(value = "代办任务子项返回结果VO", description = "对应每个人员的任务分配情况")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class BusinessTaskItemVO extends BusinessTaskItemDO {


    /**
     * 数据转换
     *
     * @param businessTaskItemDO BusinessTaskItemDO
     * @return BusinessTaskItemVO
     */
    public static BusinessTaskItemVO fromBusinessTaskItemDO(BusinessTaskItemDO businessTaskItemDO) {
        if (ObjectValidators.isEmpty(businessTaskItemDO)) {
            return null;
        }
        BusinessTaskItemVO temp = new BusinessTaskItemVO();
        BeanUtils.copyProperties(businessTaskItemDO, temp);
        return temp;
    }

    /**
     * 数据转换
     *
     * @param list BusinessTaskDO列表
     * @return BusinessTaskVO列表
     */
    public static List<BusinessTaskItemVO> fromBusinessTaskItemDO(List<BusinessTaskItemDO> list) {
        if (list == null) {
            return null;
        }
        return list.stream()
                .map(BusinessTaskItemVO::fromBusinessTaskItemDO)
                .collect(Collectors.toList());
    }

}
